﻿using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace Vision.VisionWorkshop.Common
{
    public class TextboxWriter : TextWriter
    {
        public delegate void TextWriten(string text);
        public event TextWriten TextWritenEvent;

        /// <summary>
        /// 
        /// </summary>
        public TextboxWriter()
        {
            
        }

        /// <summary>
        /// 
        /// </summary>
        public override Encoding Encoding        
        {
            get { return Encoding.Default; }
        }
                
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        public override void Write(string value)
        {                        
            if (this.TextWritenEvent != null){
                this.TextWritenEvent(value);                                
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        public override void WriteLine(string value)
        {
            if (this.TextWritenEvent != null){                
                this.TextWritenEvent(value + Environment.NewLine);
            }
        }                
    }
}
